package com.dimao.certificate_build_service.handle;

public class ValueResult<V> extends Result {
    private V value;

    public ValueResult(boolean succeed, V value, Throwable error) {
        super(succeed, error);
        this.value = value;
    }

    public V result() {
        return value;
    }

    @Override
    public boolean equals(Object obj) {
        ValueResult<V> valueResult = (ValueResult<V>)obj;
        return (super.equals(valueResult)) && (nullEquals(valueResult) || (value.equals(valueResult.value)));
    }

    private boolean nullEquals(ValueResult valueResult){
        return (value == null) && (valueResult.value == null);
    }
}
